package data

import (
	"github.com/astaxie/beego/orm"
	_ "github.com/go-sql-driver/mysql"
)

type OrderRepo struct{}

type InvoiceDto struct {
	Id        int     `orm:"pk;auto;column(id)"`
	Title     string  `orm:"column(title)"`
	Addr      string  `orm:"column(post_addr)"`
	RecvName  string  `orm:"column(recv_name)"`
	Amount    float32 `orm:"column(amount)"`
	TaxNo     string  `orm:"column(tax_no)"`
	RecvPhone string  `orm:"column(recv_phone)"`
	ZipCode   string  `orm:"column(zip_code)"`
	WaybillId int     `orm:"column(waybill_id)"`
	MemberId  int     `orm:"column(member_id)"`
	CorpId    int     `orm:"column(corp_id)"`
	State     int     `orm:"column(state)"`
}

func (dto *InvoiceDto) TableName() string {
	return "o_invoice"
}

func (repo OrderRepo) GetInvoice(waybillId int) (InvoiceDto, error) {
	var invoice InvoiceDto
	o := orm.NewOrm()
	err := o.Raw(SQL_Order_Get_Invoice, waybillId).QueryRow(&invoice)
	return invoice, err
}

func init() {
	orm.RegisterModel(new(InvoiceDto))
}
